package com.sjx.onelinecord.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.sjx.onelinecord.R

class TestFragment : Fragment() {
    private var mPosition: String? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (arguments != null) {
            mPosition = arguments!!.getInt(POSITION).toString()
        }
    }

    override fun onCreateView(inflater: LayoutInflater,
                              container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.fragment_test, null)
        val textView = view.findViewById<TextView>(R.id.tvTestFm)
        textView.text = mPosition
        return view
    }

    companion object {
        private const val POSITION = "position"
        fun newInstance(position: Int): TestFragment {
            val testFragment = TestFragment()
            val bundle = Bundle()
            bundle.putInt(POSITION, position)
            testFragment.arguments = bundle
            return testFragment
        }
    }
}